import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import 'default-passive-events'
Vue.use(ElementUI);
Vue.config.productionTip = false;
Vue.config.devtools = true;
import https from "@/utils/https";
Vue.prototype.$https = https;
import * as filter from "@/utils/filter";
Object.keys(filter).forEach(item => {
  Vue.filter(item, filter[item]);
});
window.vm = new Vue({
  router,
  store,
  render: h => h(App),
  created() {
    // 在页面加载时读取sessionStorage
    if (localStorage.getItem("store")) {
      // debugger
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(localStorage.getItem("store"))
        )
      );
      this.$store.commit('setWs')
    }
    // 在页面刷新时将store保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      // debugger
      // localStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  },
}).$mount("#app");
